//Ashish Tomar
//10/27/2008

package paths.g4;

import java.util.*;
import java.util.List;
import java.io.*;
import java.awt.*;
import java.awt.image.*;
import javax.imageio.*;

import paths.*;

import ui.Util;


public  class CityMetadata {
	
public	static boolean c1=false;

public static List<String> wonder = Arrays.asList("Agra","Paris","Athens","Kyoto","Istanbul","Moscow","Sydney","Mali","NewYork","NewYorkCity","Granada","Angkor","EasterIsland","Amesbury","Fussen","Cairo","Rome","Yucatan","RiodeJaneiro");
public static List<String> popular = Arrays.asList("NewYork", "NewYorkCity","Chicago","London","Seattle","LosAngeles","Philadelphia","Boston","SanFrancisco","Melbourne","Atlanta","Mumbai","Bombay","Singapore","Cairo","Auckland","Paris","Munich","MexicoCity");
public static List<String> asian = Arrays.asList("Kyoto","HongKong","Bangkok","Tokyo","KualaLumpur","Singapore","Goa","Katmandu","Beijing","Seoul","Shanghai","Tashkent","Taipei","Karachi","Nagasaki","Yokohama","Hiroshima","Bombay","Mumbai","Delhi","NewDelhi","Jakarta","Colombo","Pattaya","Calcutta","Kolkata","Manila","Bali","Bhopal","Indore","Patna","Agartala","Amritsar","Aurangabad","Bengaluru","Bhuj","Bhubaneswar","Chennai","Calicut","Chandigarh","Coimbatore","Dhaka","Diu","Dubai","Guwahati","Imphal","Jaipur","Jammu","Kochi","Kuwait","Jodhpur","Luchnow","Madurai","Mangalore","Nagpur","Pune","Raipur","VISHAKHAPATNAM","Varanasi","THIRUVANANTHAPURAM","Hangzhou","Wuhan","Xian","Chongqing","Weihai","Qingdao","Yantai","Dalian","Shenyang");
public static List<String> scenic = Arrays.asList("Cairo","CapeTown","Brasilia","Giza","Tehran","Prague","LasVegas","Madrid","Miami","Amsterdam","Vancouver","Jerusalem","Medellin","Valencia","Florence","Rome","Sydney","CapeTown","Beirut","SanDiego","Chicago","NewYork","NewYorkCity","Tokyo","Agra","Istanbul","Venice","Zurich","London");
public static List<String> historic = Arrays.asList("Moscow");
public static List<String> australia = Arrays.asList("Melbourne","Newcastle","Canberra","Darwin", "Cairns", "Brisbane", "Adelaide","Perth", "AliceSprings","Sydney");
public static List<String> europe = Arrays.asList("Paris", "Rome", "Munich","Zurich","Barcelona", "London", "Venice","Istanbul","Prague","Milan","Amsterdam","Glasgow","Brussels","Munich","Berlin","Lisbon","Barcelona","Madrid","Moscow","Vienna","Dublin","Birmingham","Frankfurt","LUXEMBOURG");
public static List<String> africa = Arrays.asList("CapeTown", "Cairo","Lagos","Casablanca","Giza","Benin","Durban", "Johannesburg", "Harare", "Nairobi");
public static List<String> america = Arrays.asList("Newark","Vancouver","Brasilia","Santiago","MexicoCity","Boston", "NewYork", "NewJersey","Philadelphia", "Miami", "SanJose","SanDiego","Texas","Atlanta","WashingtonDC","WashingtonD.C.","Washington","Dallas","Austin","SaltLakeCity","Denver","SanFrancisco","Seattle","LosAngeles","LasVegas","Toronto","Dallas","Indianapolis","Houston","Memphis","Phoenix","SanAntonio","Detroit","Columbus","Baltimore","Albuquerque","Cleveland");

public static String getMetaResult(ArrayList<City> route)
{
	boolean  p=false,as=false,wo=false,hi=false,sc=false,aus=false,ame=false,eur=false,afr=false;
	int pop=0,asi=0,wond=0,his=0,sce=0,aust=0,amer=0,euro=0,afri=0;
	c1=false;
	int size=route.size();
	int lim =(int)(size/3);
	ArrayList<Integer> total =new ArrayList<Integer>();
	ArrayList<Integer> conti =new ArrayList<Integer>();
    Iterator<City> it = route.iterator();
	while(it.hasNext())
	{
		City x=it.next();
		
	p=getPopular(x);
	if(p)
	{
		
		pop++;
		p=false;
	}
	as=getAsian(x);
	if(as)
	{
		
		asi++;
		as=false;
	}
	
	aus=getAustralia(x);
	if(aus)
	{
		
		aust++;
		aus=false;
	}
	
	ame=getAmerica(x);
	if(ame)
	{
		
		amer++;
		ame=false;
	}
	afr=getAfrica(x);
	if(afr)
	{
		
		afri++;
		afr=false;
	}
	
	eur=getEurope(x);
	if(eur)
	{
		
		euro++;
		eur=false;
	}
	
	
	
	wo=getWonder(x);
	if(wo)
	{
		
		wond++;
		wo=false;
	}
	hi=getHistoric(x);
	if(hi)
	{
		
		his++;
		hi=false;
	}
	sc=getScenic(x);
	if(sc)
	{
		
		sce++;
		sc=false;
	}
}
	
	
	total.add(pop);
	total.add(wond);
	total.add(his);
	total.add(sce);
	
	conti.add(asi);
	conti.add(amer);
	conti.add(euro);
	conti.add(aust);
	conti.add(afri);
	
	Object obj = Collections.max(total);
	Object obje = Collections.max(conti);
	//System.out.println("The count is "+obj+" "+pop+" "+asi+" "+wond+" "+his+" "+sce);
	if(asi>0 && amer>0 && euro>0 && aust>0)
	{
		return "Continental Tour ";
	}
	else if((Integer)obj==pop)
	{
		if(amer==(Integer)(obje) && amer >lim)
		{
		
			if(amer==aust)
			{
			return "Popular Cities Tour with American & Australian Flavour";
			}
			else if(amer==euro)
			{
				return "Popular Cities Tour with American & European Flavour";
			}
			
			else if(amer==asi)
			{
				return "Popular Cities Tour with American & Asian Flavour";
			}
			
			else if(amer==afri)
			{
				return "Popular Cities Tour with American & African Flavour";
			}
			
			else
			{
				return "Popular Cities Tour with American Flavour";
			}
			}
			
			
		else
		if(aust==(Integer)(obje) && aust >lim)
		{
			if(aust==euro)
		{
			return "Popular Cities Tour with Australian & European Flavour";
		}
		
		else if(aust==asi)
		{
			return "Popular Cities Tour with Australian & Asian Flavour";
		}
		
		else if(aust==afri)
		{
			return "Popular Cities Tour with Australian & African Flavour";
		}
		
		else
		{
			return "Popular Cities Tour with Australian Flavour";
		}
		}
		else

		if(euro==(Integer)(obje) && euro >lim)
		{
			 if(euro==asi)
			{
				return "Popular Cities Tour with European & Asian Flavour";
			}
			
			else if(euro==afri)
			{
				return "Popular Cities Tour with European & African Flavour";
			}
			
			else
			{
			
			
		return "Popular Cities Tour with European Flavour";
		}
		}
		else
		if(asi==(Integer)(obje) && asi >lim)
		{
			if(asi==afri)
			{
				return "Popular Cities Tour with Asian & African Flavour";
			}
			
			else
			{
			
			
		return "Popular Cities Tour with Asian Flavour";
		}
		}
		else
			if(afri==(Integer)(obje) && afri >lim)
			{
			return "Popular Cities Tour with African Flavour";
			}
			else
			{
				return "Popular Cities Tour";
			}


	}

	
	else if((Integer)obj==sce)
	{
		return "Scenic Cities Tour ";
	}
	
	else if((Integer)obj==his)
	{
		return "Historic Cities Tour ";
	}
	else if((Integer)obj==wond)
	{
		return "Wonder Cities Tour ";
	}
	else
	{
		return "Our Pick For You ";
	}
	
	
	
}	








public static boolean getWonder(City x)
{
	c1=false;
	Iterator<String> it = wonder.iterator();
	while(it.hasNext())
	{
		String s=it.next();
		if((x.name).equalsIgnoreCase(s))
		{
			c1= true;
			break;
		}
		else 
		{
			c1= false;
		}
	}
	
	return c1;
}	

public static boolean getPopular(City x)
	{
		
	c1=false;
	Iterator<String> it = popular.iterator();
	while(it.hasNext())
	{
		String s=it.next();
		if((x.name).equalsIgnoreCase(s))
		{
			c1= true;
			break;
		}
		else 
		{
			c1= false;
		}
	}
	
	return c1;
	}
	
	
	public static boolean getAsian(City x)
	{
		
		c1=false;
		Iterator<String> it = asian.iterator();
		while(it.hasNext())
		{
			String s=it.next();
			if((x.name).equalsIgnoreCase(s))
			{
				c1= true;
				break;
			}
			else 
			{
				c1= false;
			}
		}
		
		return c1;
	}
	
	
	
	public static boolean getAmerica(City x)
	{
		
		c1=false;
		Iterator<String> it = america.iterator();
		while(it.hasNext())
		{
			String s=it.next();
			if((x.name).equalsIgnoreCase(s))
			{
				c1= true;
				break;
			}
			else 
			{
				c1= false;
			}
		}
		
		return c1;
	}
	
	public static boolean getAfrica(City x)
	{
		
		c1=false;
		Iterator<String> it = africa.iterator();
		while(it.hasNext())
		{
			String s=it.next();
			if((x.name).equalsIgnoreCase(s))
			{
				c1= true;
				break;
			}
			else 
			{
				c1= false;
			}
		}
		
		return c1;
	}
	
	public static boolean getEurope(City x)
	{
		
		c1=false;
		Iterator<String> it = europe.iterator();
		while(it.hasNext())
		{
			String s=it.next();
			if((x.name).equalsIgnoreCase(s))
			{
				c1= true;
				break;
			}
			else 
			{
				c1= false;
			}
		}
		
		return c1;
	}
	
	public static boolean getAustralia(City x)
	{
		
		c1=false;
		Iterator<String> it = australia.iterator();
		while(it.hasNext())
		{
			String s=it.next();
			if((x.name).equalsIgnoreCase(s))
			{
				c1= true;
				break;
			}
			else 
			{
				c1= false;
			}
		}
		
		return c1;
	}
	
	public static boolean getHistoric(City x)
	{
		
		c1=false;
		Iterator<String> it = historic.iterator();
		while(it.hasNext())
		{
			String s=it.next();
			if((x.name).equalsIgnoreCase(s))
			{
				c1= true;
				break;
			}
			else 
			{
				c1= false;
			}
		}
		
		return c1;
	}
	
	public static boolean getScenic(City x)
	{
		
		c1=false;
		Iterator<String> it = scenic.iterator();
		while(it.hasNext())
		{
			String s=it.next();
			if((x.name).equalsIgnoreCase(s))
			{
				c1= true;
				break;
			}
			else 
			{
				c1= false;
			}
		}
		
		return c1;
	}
	
	
}
